﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace project_web2.AdminTool
{
    public partial class ManagerOrders : System.Web.UI.Page
    {
        DAL dal = new DAL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Login"] == null) {
                Response.Redirect("Login.aspx");
            } else {
                LoadDataForGridview();
            }
            
        }

        private void LoadDataForGridview() {
            grManagerOrders.DataSource = loadInfoOrders();
            grManagerOrders.DataBind();
        }
        private DataTable loadInfoOrders()
        {
            string sql = "select customername, pd.productname, od.createdate, od.note, od.deliveryaddress, od.total, od.totalpayment, od.[status] from Orders od, Customers ct, Order_Details oddt, Products pd where od.customerid = ct.customerid and od.orderid = oddt.orderid and oddt.productid = pd.productid";
            return dal.get_data(sql);
        }
    }
}